package hiring.tong.com.common;

import java.util.List;

/**
 * 分页实体
 */
public class PageModel<T> {
 //每次查询到的分页数据;
	private List<T> list;
//从哪一页开始，默认是1；	
	private int pageNo;
	//分页编号数
	private List<Integer> lists;
	public List<Integer> getLists() {
		return lists;
	}
	public void setLists(List<Integer> lists) {
		this.lists = lists;
	}
	public PageModel() {
	super();
}
	public PageModel(List<T> list, int pageNo, List<Integer> lists, int pageSize, int allRecords) {
		super();
		this.list = list;
		this.pageNo = pageNo;
		this.lists = lists;
		this.pageSize = pageSize;
		this.allRecords = allRecords;
	}
	public PageModel(List<T> list, int pageNo, int pageSize, int allRecords) {
		super();
		this.list = list;
		this.pageNo = pageNo;
		this.pageSize = pageSize;
		this.allRecords = allRecords;
	}
	//每页显示多少条数据，默认10条;	
	private int pageSize;
//总共有多少条数据;	
	private int allRecords;
	public List<T> getList() {
		return list;
	}
	public void setList(List<T> list) {
		this.list = list;
	}
	/**
	 * 总共有多少页
	 */
	public int getTotalpage(){
		return (int)Math.ceil((double)allRecords/pageSize);
	}
	/**
	 * 首页
	 */
	public int getFirst(){
		return 1;
	}
	/**
	 * 上一页
	 */
	public int getPre(){
		if(pageNo==1){
			return 1;
		}
		else{
			return pageNo-1;	
		}
	}
	/**
	 * 下一页
	 */
	public int getNext(){
		if(pageNo==getTotalpage()){
			return getTotalpage();
		}
		else{
			return pageNo+1;	
		}
	}
	/**
	 * 尾页
	 */
	public int getLast(){
		return getTotalpage();
	}
	public int getPageNo() {
		return pageNo;
	}
	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getAllRecords() {
		return allRecords;
	}
	public void setAllRecords(int allRecords) {
		this.allRecords = allRecords;
	}
	
	
	
	
	
	
	
	
}
